package com.liangwj.springbootdesignpatterns.createTypePatterns.singleton;
/**
 * <b>Description:</b> 单例模式基本实现 <br/>
 * @author Lingwenjun
 * @date 2019/1/22-11:07
 * @version 1.0
 */
public class SingletonObject {
    //创建一个静态 SingletonObject 对象
    private static SingletonObject singletonObject = new SingletonObject();
    //构造函数私有化, 无法实例化
    private SingletonObject() {

    }
    //获取唯一可用实例对象(提供静态实例方法)
    public static SingletonObject getInstance() {
        return singletonObject;
    }
    //其他方法
    public void showMessage() {
        System.out.println("asdfasdfasdf");
    }

    public static void main(String[] args) {
        SingletonObject instance = SingletonObject.getInstance();
        instance.showMessage();
    }
}
